package br.com.neb.carona;


import java.util.Date;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		ListView lista = (ListView) findViewById(R.id.lista);
		String[] itens = new String[]{"Item 1", "Item 2", "Item 3","Item 4"};
		lista.setAdapter(new ArrayAdapter<String>(MainActivity.this,R.layout.item_menu,itens));
		lista.setOnItemClickListener(new ListView.OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				selectItem(position);
			}
		});
		
		final DatePicker dp = (DatePicker) findViewById(R.id.myDatePicker);
		Button btn = (Button) findViewById(R.id.btnShowDate);
		btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Toast.makeText(getApplicationContext(), "Data selecionada " + new Date(dp.getCalendarView().getDate()).toString(), Toast.LENGTH_LONG).show();
			}
		});
	}
	
	private void selectItem(int position)
	{
		Toast.makeText(getApplicationContext(), String.valueOf(position), Toast.LENGTH_LONG).show();
	}
}
